using DaoHang.Models;

namespace DaoHang.Services
{
    /// <summary>
    /// 网站服务接口，定义网站相关的业务操作
    /// </summary>
    public interface IWebsiteService
    {
        /// <summary>
        /// 获取所有网站列表
        /// </summary>
        /// <returns>网站列表</returns>
        Task<List<Website>> GetAllWebsitesAsync();

        /// <summary>
        /// 根据分类ID获取网站列表
        /// </summary>
        /// <param name="categoryId">分类ID</param>
        /// <returns>网站列表</returns>
        Task<List<Website>> GetWebsitesByCategoryAsync(int categoryId);

        /// <summary>
        /// 根据分类ID获取网站列表（兼容名称）
        /// </summary>
        /// <param name="categoryId">分类ID</param>
        /// <returns>网站列表</returns>
        Task<List<Website>> GetWebsitesByCategoryIdAsync(int categoryId) => GetWebsitesByCategoryAsync(categoryId);

        /// <summary>
        /// 根据ID获取网站详情
        /// </summary>
        /// <param name="id">网站ID</param>
        /// <returns>网站信息</returns>
        Task<Website?> GetWebsiteByIdAsync(int id);

        /// <summary>
        /// 添加新网站
        /// </summary>
        /// <param name="website">网站信息</param>
        /// <returns>添加的网站</returns>
        Task<Website> AddWebsiteAsync(Website website);

        /// <summary>
        /// 快速添加新网站（不下载图标）
        /// </summary>
        /// <param name="website">网站信息</param>
        /// <returns>添加的网站</returns>
        Task<Website> AddWebsiteQuickAsync(Website website);

        /// <summary>
        /// 创建新网站
        /// </summary>
        /// <param name="website">网站信息</param>
        /// <returns>是否创建成功</returns>
        Task<bool> CreateWebsiteAsync(Website website);

        /// <summary>
        /// 更新网站信息
        /// </summary>
        /// <param name="website">网站信息</param>
        /// <returns>更新的网站</returns>
        Task<Website> UpdateWebsiteAsync(Website website);

        /// <summary>
        /// 删除网站
        /// </summary>
        /// <param name="id">网站ID</param>
        /// <returns>删除是否成功</returns>
        Task<bool> DeleteWebsiteAsync(int id);

        /// <summary>
        /// 自动获取网站图标
        /// </summary>
        /// <param name="url">网站URL</param>
        /// <returns>图标URL</returns>
        Task<string?> GetWebsiteIconAsync(string url);

        /// <summary>
        /// 获取网站标题
        /// </summary>
        /// <param name="url">网站URL</param>
        /// <returns>网站标题</returns>
        Task<string?> GetWebsiteTitleAsync(string url);
        
        /// <summary>
        /// 增加网站访问次数
        /// </summary>
        /// <param name="id">网站ID</param>
        /// <returns>是否增加成功</returns>
        Task<bool> IncrementVisitCountAsync(int id);

        /// <summary>
        /// 后台异步更新网站图标
        /// </summary>
        /// <param name="websiteUrl">网站URL</param>
        /// <returns>是否更新成功</returns>
        Task<bool> UpdateWebsiteIconAsync(string websiteUrl);
    }
} 